/**
 * FileName: http请求的封装
 * Created Date: 2022-10-18 18:28:44
 * Author: 文初阳
 * -----
 * Last Modified: 2022-10-18 18:28:44
 * Modified By: 文初阳
 */

import { Modal } from 'antd';
import axios from 'axios';

const ROOT_URL = 'https://riki.zj.cn/wency/resumes/';

export function commonService({ type, url, params }: { type?: string; url: string; params: object }) {
    return axios({
        method: type || 'post',
        url: ROOT_URL + url,
        data: params || {},
        headers: { token: 'd51d96a9-0b21-45b3-81f9-9001ddb91947' },
    })
        .catch((error: any) => console.log(error))
        .then((res: any) => {
            const { errCode = '', errMessage = '', data = {} } = res || {};
            if (errCode !== '0000') {
                return Modal.info({
                    title: '接口错啦',
                    content: errMessage,
                });
            }
            return data;
        });
}
